package com.jwt.demo.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jwt.demo.entity.User;
import com.jwt.demo.mapper.UserMapper;
import com.jwt.demo.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * (JwtTest)表服务实现类
 *
 * @author makejava
 * @since 2021-08-27 17:38:32
 */
@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService {

    UserMapper userMapper;

    @Autowired
    public void init(UserMapper userMapper) {
        this.userMapper = userMapper;
    }

    @Override
    public List<User> getByUserName(String username) {
        return userMapper.selectList(new QueryWrapper<User>().lambda().eq(User::getUsername, username));
    }

    @Override
    public User checkUser(User user) {
        return userMapper.selectOne(new QueryWrapper<User>().lambda().eq(User::getUsername, user.getUsername())
                .eq(User::getPassword, user.getPassword()));
    }
}
